﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CXMLStudioIDE.Common;
using CXMLStudioIDE.Common.Entities;

namespace CXMLStudioIDE.Common.Entities
{
    public partial class Solution : Entity
    {
        #region Declarations

        public ProjectCollection Projects;

        #endregion

        #region Constructors

        public Solution(int SolutionID,string SolutionName)
        {
            this.ID = SolutionID;
            this.Name = SolutionName;
            Projects = new ProjectCollection();
        }

        public Solution()
        {
        }

        #endregion

        #region Methods

        public void CreateProjectList()
        {
            Projects = new ProjectCollection();
        }

        public Solution GetSolution()
        {
            return this;
        }

        public void AddProjectToSolution(Project p)
        {
            if (this != null)
            {
                this.Projects.Add(p);
            }
        }

        public ProjectCollection GetProjects()
        {
            return Projects;
        }

        public BusinessEntityCollection GetBusinessEntitiesInSolution()
        {
            BusinessEntityCollection bec = new BusinessEntityCollection();
            for (int i = 0; i < Projects.Count; i++)
            {
                for (int l = 0; l < Projects[i].Entities.Count; l++)
                {
                    bec.Add(Projects[i].Entities[l]);
                }
            }
            return bec;
        }

        #endregion
    }
}
